﻿using System;
using System.Net;
using System.Collections.Generic;

namespace ClassesToSerialize
{
#if !NO_SILVERLIGHT
    public class SerializableAttribute : Attribute
    {
    }
#endif

    [Serializable]
    public enum ItemWearType
    {
        None = 0,
        Head = 1,
        Arms = 2,
        Legs = 3,
        Body = 4
    };

    [Serializable]
    public class Stats
    {
        public short _health;
        public short _maxHealth;

        public short Health
        {
            get { return _health; }
            set { _health = value; }
        }

        public short MaxHealth
        {
            get { return _maxHealth; }
            set { _maxHealth = value; }
        }
    }

    [Serializable]
    public class DemoMonster
    {
        public string _name;

        public int _level;

        public List<Item> _items = new List<Item>();

        public Stats _stats = new Stats();

        public Stats Stats
        {
            get { return _stats; }
        }

        public List<Item> Items
        {
            get { return _items; }
        }

        public string Name
        {
            get { return _name; }
            set { _name = value; }
        }

        public int Level
        {
            get { return _level; }
            set { _level = value; }
        }

        public static string CreateDummyName()
        {
            int index = NameFactory._rand.Next(0, NameFactory.MonsterNames.Length);
            return NameFactory.MonsterNames[index];
        }
    }

    [Serializable]
    public class Item
    {
        public string _name;

        public short _uses;

        public ItemWearType _wearType;

        public string Name
        {
            get { return _name; }
            set { _name = value; }
        }

        public short Uses
        {
            get { return _uses; }
            set { _uses = value; }
        }

        public ItemWearType WearType
        {
            get { return _wearType; }
            set { _wearType = value; }
        }

        public static string CreateDummyName()
        {
            int index = NameFactory._rand.Next(0, NameFactory.ItemNames.Length);
            return NameFactory.ItemNames[index];
        }
    }

    public static class NameFactory
    {
        public static Random _rand = new Random();

        public static string[] ItemNames = new string[]
        {
            "Sword",
            "Gold"
        };

        public static string[] MonsterNames = new string[]
        {
            "Fred",
            "Goober"
        };
    }
}
